Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text. Here is some text.

Sub-head if needed

library(stringr)
library(ggplot2)
library(grid)
library(plotly)
set.seed(122)
data <- read.csv("./data/matrimoney.csv", header = TRUE, stringsAsFactor = FALSE)
table(data$Wanted)
## 
## Bride Groom 
##    32    63
grooms <- subset(data, Ad.giver == "Boy")

g.adj <- unlist(strsplit(gsub('[[:punct:]](?!\\w)', '', grooms$Self.description, perl=T), ' '))
g.adj <- gsub("-family", "", g.adj)
g.adj <- data.frame(table(tolower(g.adj)))
g.adj <- g.adj[order(-g.adj$Freq),]
g.adj$dot.x <- rnorm(n=nrow(g.adj), 12, 3)
g.adj$dot.y <- rnorm(n=nrow(g.adj), 35, 3)
g.match <- unlist(strsplit(gsub('[[:punct:]](?!\\w)', '', grooms$Partner.preference.adjective, perl=T), ' '))
g.match <- data.frame(table(tolower(g.match)))
g.match <- g.match[order(-g.match$Freq),]
g.match$dot.x <- rnorm(n=nrow(g.match), 13, 3)
g.match$dot.y <- rnorm(n=nrow(g.match), 12, 4)
brides <- subset(data, Ad.giver == "Girl")
b.adj <- unlist(strsplit(gsub('[[:punct:]](?!\\w)', '', brides$Self.description, perl=T), ' '))
b.adj <- gsub("-family", "", b.adj)
b.adj <- data.frame(table(tolower(b.adj)))
b.adj <- b.adj[order(-b.adj$Freq),]
b.adj$dot.x <- rnorm(n=nrow(b.adj), 37, 4)
b.adj$dot.y <- rnorm(n=nrow(b.adj), 35, 4)
b.match <- unlist(strsplit(gsub('[[:punct:]](?!\\w)', '', brides$Partner.preference.adjective, perl=T), ' '))
b.match <- data.frame(table(tolower(b.match)))
b.match <- b.match[order(-b.match$Freq),]
b.match$dot.x <- rnorm(n=nrow(b.match), 35, 4)
b.match$dot.y <- rnorm(n=nrow(b.match), 15, 4)
g.adj$cat <- "g.adj"
g.match$cat <- "g.match"
b.adj$cat <- "b.adj"
b.match$cat <- "b.match"
two <- rbind(g.adj, g.match, b.adj, b.match)
two <- do.call(rbind, lapply(unique(two$cat), function(t){
    xyz <- subset(two, cat == t)
    top <- head(xyz, 7)
    xyz$labs <- ifelse(xyz$Var1 %in% top$Var1,
                       as.character(xyz$Var1), NA)
    xyz
}))

two <- do.call(rbind, lapply(unique(two$cat), function(t){
    xyz <- subset(two, cat == t)
    top <- head(xyz, 7)
    xyz$labs <- ifelse(xyz$Var1 %in% top$Var1,
                       as.character(xyz$Var1), NA)
    xyz
}))

abc <- ggplot(two) + 
    geom_rect(aes(xmin = 26, xmax = 49, ymin = 2, ymax = 48),
              fill = "lightblue1") +
    geom_rect(aes(xmin = 2, xmax = 24, ymin = 2, ymax = 48),
              fill = "#F4F3AB") +
    geom_hline(yintercept=25, color = "orchid4", size=2.5) +
    geom_vline(xintercept=25, color = "orchid4", size=2.5) +
    geom_rect(aes(xmin = 23, xmax = 27, ymin = 44, ymax = 48),
              fill = "orchid4") +
    geom_rect(aes(xmin = 2, xmax = 6, ymin = 23, ymax = 27),
              fill = "tan1") +
    geom_rect(aes(xmin = 44, xmax = 48, ymin = 23, ymax = 27),
              fill = "tan1") +
    geom_rect(aes(xmin = 23, xmax = 27, ymin = 2, ymax = 6),
              fill = "orchid4") +    
   theme(
       axis.ticks.x=element_blank(), 
       axis.text.x=element_blank(),
       axis.ticks.y=element_blank(),
       axis.text.y=element_blank(),
       plot.margin=unit(c(2,1,1,1),"cm")
       ) + 
    scale_x_continuous(expand = c(0, 0), limits = c(0, 50)) +
    scale_y_continuous(expand = c(0, 2), limits = c(0, 50)) +          
    geom_point(aes(dot.x, dot.y,
                   text = Var1),
               colour = "thistle3", size = two$Freq) + 
    geom_text(aes(dot.x, dot.y, label=labs),colour="lightsalmon4",
              size=4, parse = TRUE) +
    annotate("text", x=25, y=46, label="For\nself",
             colour="white",
             size=4) +
    annotate("text", x=25, y=4, label="For\nmatch",
             colour="white",
             size=4) +
    annotate("text", x=4, y=25, label="Ad by\ngroom",
             colour="black",
             size=4) +
    annotate("text", x=46, y=25, label="Ad by\nbride",
             colour="black",
             size=4) +
    theme_void() +
    annotate("text", x = 42, y = 0,
             label = "As used in ads printed on July 19\nin a leading daily",               size = 4,
             family = "Ume P Mincho S3",
             colour = "black") +
    annotate("text", x = 15, y = 50,
             label = "Adjectives used in a day's worth of matrimonial",
             size = 6,
             family = "Ume P Mincho S3",
             colour = "black")   
## Warning: Ignoring unknown aesthetics: text
ax <- list(
    zeroline = FALSE,
    showline = FALSE,
    showticklabels = FALSE,
    showgrid = FALSE
)

titlefont = list(
                family = "Agency FB",
                size = 30,
                color = '#ffffff')

p <- ggplotly(abc, tooltip = "text") %>% layout(xaxis = ax, yaxis = ax)  %>%
    layout(hoverlabel = list(bgcolor= 'indianred2'),
           font = list(
                family = "Agency FB",
                size = 30,
                color = '#ffffff'))

p